import Vue from 'vue'
import App from './App.vue'
// import router from './router'
import store from './store'
import Element from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/element-ui-theme/index.css'
import '@/style/index.less'
import '@/style/pacs/pacs.less'
import qs from 'qs'
import validation from './utils/validation'
import pacsApi from '@/api/pacs.js'
import inputInt from '@/directive/input-int'
import dragDialog from '@/directive/el-drag-dialog'
import commonFilter from '@/filters'

import { setAxiosConfig } from '@/utils/request'
import { setRouterConfig } from './router'
// import loadConfigScript from '@/utils/loadConfigScript'

console.log('这里哦？11,main.js');

const product = '/paservice/' // **各自项目名称，注意修改**

window.Config = {}
if (window.location.pathname.indexOf(product) !== 0) {
  // 说明是虚拟目录
  window.Config.subdir = window.location.pathname.substring(0, window.location.pathname.indexOf(product))
} else {
  window.Config.subdir = ''
}
if (process.env.NODE_ENV === 'production') {
  console.log(`%c项目打包时间：${BUILD_DATE} - ${BRANCH} - ${VERSION}`, 'color: #0a70b0;font-weight: bold;')
}
new Promise((resolve, reject) => {
  const script = document.createElement('script')
  script.type = 'text/javascript'
  script.src = `${window.Config.subdir}/config/config.js`
  script.onload = () => {
    console.log('加载/config/config.js 成功')
    resolve()
  }

  console.log('开始 /config/config.js')
  document.getElementsByTagName('head')[0].appendChild(script)
}).then(() => {
  setAxiosConfig()  // 初始化 Axios
  const router = setRouterConfig() // 初始化router
  Vue.prototype.$pacsApi = pacsApi
  Vue.config.productionTip = false
  Vue.prototype.$qs = qs
  Vue.use(Element)
  Vue.use(validation)
  Vue.use(dragDialog)
  Vue.use(inputInt)
  Vue.use(commonFilter)
  new Vue({
    router,
    store,
    render: h => h(App)
  }).$mount('#app')
})
// loadConfigScript().then(() => {
//   setAxiosConfig()  // 初始化 Axios
//   const router = setRouterConfig() // 初始化router
//   Vue.prototype.socketApi = socketApi
//   Vue.prototype.$pacsApi = pacsApi
//   Vue.config.productionTip = false
//   Vue.prototype.$qs = qs
//   console.log('console.log(process.env);', process.env)
//   Vue.use(Element)
//   Vue.use(validation)
//   Vue.use(inputInt)
//   // ....
//   // ....
//   // ....
//   new Vue({
//     router,
//     store,
//     render: h => h(App)
//   }).$mount('#app')
// })
